package com.xwltz.controller;

import com.xwltz.entity.Student;
import com.xwltz.service.StudentService;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/student")
@CrossOrigin
public class StudentController {

    private final StudentService service;

    public StudentController(StudentService service) {
        this.service = service;
    }

    @GetMapping("/list")
    public List<Student> list() {
        return service.findAll();
    }

    @GetMapping("/get/{id}")
    public Student getById(@PathVariable("id") long id) {
        return service.findById(id);
    }
}
